﻿namespace WMS6.Web.OrderManagement
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class OnLinePOQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCreatedByOper;
        protected DropDownList ddlExternPoIDOper;
        protected DropDownList ddlOwnerIDOper;
        protected DropDownList ddlPoDateOper;
        protected DropDownList ddlPoIDOper;
        protected DropDownList ddlRequestDeliveryDateOper;
        protected DropDownList ddlStatusOper;
        protected DropDownList ddlVendorIDOper;
        protected HtmlForm F3040;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img1;
        protected HtmlImage img3;
        protected Label lblCreatedBy;
        protected Label lblExternPoID;
        protected Label lblOwnerID;
        protected Label lblPoDate;
        protected Label lblPoID;
        protected Label lblRequestDeliveryDate;
        protected Label lblSalesOrder;
        protected Label lblStatus;
        protected Label lblVendorID;
        protected MultipleSelectControl MSCStatus;
        protected HtmlLink mycss;
        protected TextBox txtCreatedBy;
        protected TextBox txtExternPoID;
        protected TextBox txtOwnerID;
        protected TextBox txtPoDate;
        protected TextBox txtPoDate2;
        protected TextBox txtPoID;
        protected TextBox txtRequestDeliveryDate;
        protected TextBox txtRequestDeliveryDate2;
        protected TextBox txtVendorID;

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("OnLinePOList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.hdnActionID.Value = base.Request.QueryString["action"].ToString();
            }
        }

        private void LoadDLL()
        {
            base.InitQueryDDL(this.ddlPoIDOper, 0);
            base.InitQueryDDL(this.ddlCreatedByOper, 1);
            base.InitQueryDDL(this.ddlExternPoIDOper, 1);
            base.InitQueryDDL(this.ddlOwnerIDOper, 0);
            base.InitQueryDDL(this.ddlPoDateOper, 1);
            base.InitQueryDDL(this.ddlRequestDeliveryDateOper, 0);
            base.InitQueryDDL(this.ddlStatusOper, 0);
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
            base.BindData2DDLBySysCode(this.MSCStatus, "POStatus");
            this.ddlStatusOper.SelectedValue = "One Of";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDLL();
                this.LoadData();
            }
        }

        public string CreatedBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedBy.Text.Trim(), this.ddlCreatedByOper.SelectedValue);
                }
                return "";
            }
        }

        public string ExternalPoID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternPoID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternPoID.Text.Trim(), this.ddlExternPoIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string PoDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPoDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPoDate.Text.Trim(), this.ddlPoDateOper.SelectedValue, this.txtPoDate2.Text.Trim());
                }
                return "";
            }
        }

        public string poID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPoID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPoID.Text.Trim(), this.ddlPoIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string RequestDeliveryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtRequestDeliveryDate.Text.Trim()))
                {
                    string strRequestDeliveryDate2 = string.Empty;
                    if (!string.IsNullOrEmpty(this.txtRequestDeliveryDate2.Text))
                    {
                        strRequestDeliveryDate2 = DateTime.Parse(this.txtRequestDeliveryDate2.Text).ToString("yyyy-MM-dd");
                    }
                    return base.GetParamsString(DateTime.Parse(this.txtRequestDeliveryDate.Text.Trim()).ToString("yyyy-MM-dd"), this.ddlRequestDeliveryDateOper.SelectedValue, strRequestDeliveryDate2);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCStatus.ReturnValue))
                {
                    return base.GetParamsString(this.MSCStatus.ReturnValue, this.ddlStatusOper.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text.Trim(), this.ddlVendorIDOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

